Specifies that every variable in the program code must be explicitly declared with the Dim statement.
プログラムコード中で使用するすべての変数を、Dim ステートメントを使って明示的に宣言する必要があるようにします。
Option Explicit
Option Explicit
![]() | This statement must be added before the executable program code in a module.
このステートメントを記述するプログラム中の位置は、モジュール内のすべての実行コードよりも前にする必要があります。 |
Option Explicit
Option Explicit
Sub ExampleExplicit
Sub ExampleExplicit
Dim sVar As String
Dim sVar As String
sVar = "Las Vegas"
sVar = "Las Vegas"
For i% = 1 to 10 REM This results in a run-time error
For i% = 1 to 10 REM これは実行時エラーとなります
REM
REM
Next i%
Next i%
End Sub
End Sub